<h1>Listing posts</h1>

<table>
  <tr>
    <th>Title</th>
    <th>Author</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @posts.each do |post| %>
  <tr>
    <td><%= post.title %></td>
    <td><%= post.name %></td>
    <td><%= link_to 'Show', post %></td>
	
	<% if session[:user].id == post.author_id %>
		<td><%= link_to 'Edit', edit_post_path(post) %></td>
	<% end %>
	
	<% if session[:user].authority == "admin" or session[:user].authority == "manager" or session[:user].id == post.author_id %>	
		<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
	<% end %>	
	</tr>
<% end %>
</table>

<br />


<%= link_to 'New Post', new_post_path %>


<br>